import { _decorator, Component, Node, v3, Vec3, tween } from 'cc';
import { popRoute } from '../common/Utils';
import Global from '../common/Global';

const { ccclass, property } = _decorator;

@ccclass('TravelLevelPopup')
export class TravelLevelPopup extends Component {
	next: Node = null;
	back: Node = null;
	@property
	maxLevel: number = 1;
	// startScale: Vec3 = v3(0.5, 0.5, 1);
	// endScale: Vec3 = v3(1, 1, 1);
	container: Node = null!;
	protected onLoad(): void {
		console.log('load');
	}

	start() {
		// this.container.setScale(this.startScale);
	}

	protected onEnable(): void {
		console.log('onEnable');

		this.container = this.node.getChildByName('Container');
		this.next = this.container.getChildByName('Next');
		this.back = this.container.getChildByName('Back');
		this.isLastLevel(this.maxLevel === Global.gameOrderBy);
		// console.log("enable");
		// tween(this.container).to(0.3, { scale: this.endScale }).start();
	}

	backRoute() {
		popRoute();
	}
	isLastLevel(bool: boolean) {
		if (bool) {
			this.next.active = false;
			this.back.setPosition(0, -193);
		} else {
			this.next.active = true;
			this.back.setPosition(-204, -193);
		}
	}
	update(deltaTime: number) {}
}
